package com.third.share;

import android.app.Activity;
import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.text.Layout;
import android.view.LayoutInflater;
import android.view.View;

import com.third.login.R;
import com.third.login.ThirdLoginPlatform;
import com.third.share.view.ThirdShareItem;

import android.widget.Button;

import java.util.zip.Inflater;

/**
 * Created by Administrator on 2017-11-07.
 */

public abstract class ThirdShareDialog extends Dialog implements View.OnClickListener{
    private Button btnCancel;
    protected ThirdShareOperatorBase mThirdShare;
    protected View mMainView;
    protected ShareData mShareData;
    public ThirdShareDialog(@NonNull Context context) {
        super(context, R.style.Share_Dialog_Fullscreen_Transparent);
    }

    public void onCreate(Bundle bundle){
        super.onCreate(bundle);
        mMainView = LayoutInflater.from(getContext()).inflate(R.layout.third_share_layout,null);
        setContentView(mMainView);
        mMainView.setOnClickListener(new View.OnClickListener(){

            @Override
            public void onClick(View view) {
                closeDilaog();
            }
        });
        init();
        if(mThirdShare != null){
            mThirdShare.onCreate(bundle);
            mThirdShare.setOnClickListener(this);
            mThirdShare.setShareData(mShareData);
        }
    }

    protected abstract void init();

    public void showDialog(){
        if(!isShowing()){
           show();
        }
    }

    public void setShareData( ShareData shareData){
        mShareData = shareData;
        if(mThirdShare != null){
            mThirdShare.setShareData(shareData);
        }
    }

    public void closeDilaog(){
        if(isShowing()){
            dismiss();
        }
    }

    public void onClick(View view){
        if(mThirdShare != null){
            mThirdShare.onClick(view);
        }
        closeDilaog();
    }
}
